package game.resource.loader.tagparser;

import org.xml.sax.Attributes;

import common.Log;

public class RegularSheetTagParser implements TagParser_I {
	public String Name;
	public String ImageFile;
	public String MaskFile;
	public int Rows = 1;
	public int Cols = 1;
	
	@Override
	public boolean parse(String tag, Attributes attributes) {
		if(!tag.toLowerCase().equals("regularsheet")) {
			return false;
		}

		Name = attributes.getValue("name");
		if(Name == null) {
			Log.error("Missing name attribute.");
		}
		ImageFile = attributes.getValue("imagefile");
		if(ImageFile == null) {
			Log.error("Missing imagefile attribute.");
		}
		
		try {
			Rows = Integer.parseInt(attributes.getValue("rows"));
			Cols = Integer.parseInt(attributes.getValue("cols"));
		} catch (NumberFormatException e) {
			Rows = 1;
			Cols = 1;
			Log.warning("Bad format of 'rows' or 'cols' value string.");
		}
		
		MaskFile = attributes.getValue("maskfile");
		
		return (Name != null && ImageFile != null);
	}

}
